package com.exam.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.exam.entity.Book;
import com.exam.mapper.BookMapper;
import com.exam.service.BookService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author D
 * @since 2023-03-18 10:27:29
 */
@Service
public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements BookService {
    @Autowired
    BookMapper bookMapper;

    @Override
    public Page<Book> getBookListByPage(Integer page, Integer pageSize) {
        Page<Book> pages = new Page<>(page, pageSize);
        QueryWrapper<Book> bookQueryWrapper = new QueryWrapper<>();

        bookQueryWrapper.orderByDesc("buycount");

        return bookMapper.selectPage(pages, bookQueryWrapper);
    }
}
